download_rabbitmq-c:
  cmd.run:
    - name: |
        cd /srv/files/
        wget https://github.com/alanxz/rabbitmq-c/archive/v0.8.0.tar.gz
    - unless: test -f /srv/files/v0.8.0.tar.gz

{% if 1==2 %}
download_php-devel:
  cmd.run:
    - name: |
        cd /srv/files/
        wget ftp://rpmfind.net/linux/fedora/linux/updates/24/x86_64/p/php-devel-5.6.23-1.fc24.x86_64.rpm
    - unless: test -f /srv/files/php-devel-5.6.23-1.fc24.x86_64.rpm
{% endif %}

download_amqp:
  cmd.run:
    - name: |
        cd /srv/files/
        wget http://pecl.php.net/get/amqp-1.7.0.tgz
    - unless: test -f /srv/files/amqp-1.7.0.tgz


unzip_rabbitmq-c:
  archive.extracted:
    - name: /tmp/
    - source: /srv/files/v0.8.0.tar.gz
    - archive_format: tar
    - tar_options: zxvf
    - if_missing: /tmp/rabbitmq-c-0.8.0
    - unless: test -d /tmp/rabbitmq-c-0.8.0


unzip_amqp:
  archive.extracted:
    - name: /tmp/
    - source: /srv/files/amqp-1.7.0.tgz
    - archive_format: tar
    - tar_options: zxvf
    - if_missing: /tmp/amqp-1.7.0
    - unless: test -d /tmp/amqp-1.7.0


install:
  cmd.run:
    - name: |
        yum -y install librabbitmq-devel.x86_64
        cd /tmp/rabbitmq-c-0.8.0
        wget https://github.com/rabbitmq/rabbitmq-codegen/tarball/master
        tar zxvf master 
        mv rabbitmq-* codegen
        autoreconf -i && ./configure && make && sudo make install        
        #rpm -ivh /srv/files/php-devel-5.6.23-1.fc24.x86_64.rpm --nodeps
        cd /tmp/amqp-1.7.0
        phpize && ./configure --with-amqp && make && sudo make install
    - unless: test -f /etc/init.d/rabbitmq-server

php-amqp.ini:
  file.managed:
    - name: /etc/php.d/amqp.ini
    - source: salt://rabbitmq/files/amqp.ini
    - unless: test -f /etc/php.d/amqp.ini

restart-service:
  cmd.run:
    - name: service php-fpm restart